lobsterlayui.main(['index', 'layer', 'form', 'element', 'table'], {
    data: {
        $layui: null,
        info: null,
        list: []
    },
    pageload: function (right) {
        console.log(right);

        this.initevent();

        var item = parent.currData;

        if (item.OrderState == 1 || item.OrderState == 0) {
            item.OrderStateTxt = "待支付";
        } else if (item.OrderState == 2) {
            item.OrderStateTxt = "已支付";
        } else if (item.OrderState == 5) {
            item.OrderStateTxt = "已取消";
        } else if (item.OrderState == 6) {
            item.OrderStateTxt = "退款中";
        } else {
            item.OrderStateTxt = "已退款";
        }

        if (item.PayMode == 1) {
            item.PayModeTxt = '微信';
        }
        else if (item.PayMode == 2) {
            item.PayModeTxt = '医保';
        } else {
            item.PayModeTxt = '其他';
        }

        if (item.PayStatus == 1) {
            item.PayStatusTxt = "未支付";
        } else if (item.PayStatus == 2) {
            item.PayStatusTxt = "已支付";
        } 

        this.data.info = item;
        this.viewTemp();

        this.loadData();
    },
    viewTemp: function () {
        console.log(this.data.info);
        var getTpl = datatemp.innerHTML, view = document.getElementById('dataview');
        layui.laytpl(getTpl).render(this.data.info, function (html) {
            view.innerHTML = html;
            layui.form.render();
        });
    },
    initevent() {
        var self = this;
    },
    loadData() {
        var self = this;
        layui.table.render({
            elem: '#datatable',
            where: {id:self.data.info.Id},
            headers: lobsterlayui.GetHeaderData(),
            url: lobsterlayui.GetLowCodeUrl('tsselfpay.getpresfeelist_web'),
            height: 'full',
            cellMinWidth: 80,
            size: 'sm',
            //toolbar: '#toolbar',
            //page: true,
            even: true,
            cols: [[
                
                { field: 'ItemName', title: '项目名称', width: "80%", },             
                { field: '', title: '数量', align: 'left', width: "20%", templet: (d) => { return (d.UnitPrice*d.Quantity).toString()+d.Unit ; } },
            ]],
            parseData: function (res) {
                return {
                    code: res.code,
                    msg: res.msg,
                    count: 0,
                    data: res.data.list
                }
            }
        });
    },
})